package test.maven.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import test.maven.model.Client;
import test.maven.service.ClientService;

@Controller
public class ClientController {
	
	private Client client;
	
	@Autowired 
    private ClientService clientService;

	@RequestMapping(value="/index",  method= RequestMethod.GET)
	public ModelAndView test(HttpServletResponse response) throws IOException{
		client= new Client("RAKOTOVAO","MIJORO");
		 try {
				clientService.saveClient(client);
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		System.out.println("MON CLIENT : "+client.getNom() +" "+client.getPrenom());
		return new ModelAndView("index");
	}
}
